package com.example.vueserver.vueserver.dao;

import com.example.vueserver.vueserver.bean.SysUser;
import com.example.vueserver.vueserver.dao.sqlprovider.SysUserSQLProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SysUserMapper {
    @Select("SELECT * FROM sys_user WHERE id = #{id}")
    SysUser selectById(Integer id);

    @Select("SELECT * FROM sys_user WHERE name = #{name}")
    SysUser selectByName(String name);

    @Select("select * from sys_user order by id")
    List<SysUser> list();

//    @Insert("insert into sys_user (name,password) values(#{name},#{password})")
//    @SelectKey(keyColumn="id", keyProperty="id", resultType=Integer.class, before=false, statement="select last_insert_id()")
    @InsertProvider(type = SysUserSQLProvider.class, method = "insertSQL")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")//获取最新插入的记录ID返回至sysUser属性中
    Integer save(@Param("sysUser") SysUser sysUser);

    @UpdateProvider(type = SysUserSQLProvider.class, method = "updateSQL")
    Integer update(@Param("sysUser") SysUser sysUser);
}

